

export function genBase64() {
  return {
    encrypt: (target) => {
      if (target) {
        return btoa(unescape(encodeURIComponent(JSON.stringify(target))));
      } else {
        throw Error("请提供需要加密的内容");
      }
    },
    decrypt: (target: string) => {
      return JSON.parse(decodeURIComponent(escape(atob(target))));
    },
  };
}

const base64 = genBase64()

export {
  base64
}
